//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.ruoyi.common.utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class PubDbFunctions {
    public PubDbFunctions() {
    }

    public static Connection getConnection_Mssq(String dbName, String dbIp, String dbPort, String dbUser, String dbPwd) {
        String driverClass = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
        String url = "jdbc:sqlserver://" + dbIp + ":" + dbPort + ";DatabaseName=" + dbName;
        Connection con = null;

        try {
            Class.forName(driverClass);
            con = DriverManager.getConnection(url, dbUser, dbPwd);
            return con;
        } catch (Exception var9) {
            var9.printStackTrace();
            return con;
        }
    }

    public static Connection getConnection_Oracle(String dbName, String dbIp, String dbPort, String dbUser, String dbPwd) {
        String driverClass = "oracle.jdbc.OracleDriver";
        String url = "jdbc:oracle:thin:@" + dbIp + ":" + dbPort + ":" + dbName;
        Connection con = null;

        try {
            Class.forName(driverClass);
            con = DriverManager.getConnection(url, dbUser, dbPwd);
            return con;
        } catch (Exception var9) {
            var9.printStackTrace();
            return con;
        }
    }

    public static void closeConnection(Connection con) {
        try {
            if (con != null) {
                con.close();
            }
        } catch (SQLException var2) {
            var2.printStackTrace();
        }

    }
}
